// Register bookmark_buttons
BloggerExt.bookmark_buttons = function() {
    
    // process each posts at ListMode and ItemMode
    jQuery('div.post').each( function (i) {
            var post_titleLinkObj = jQuery(this).find('.post-title a');
            var post_title = encodeURIComponent(post_titleLinkObj.text());
            var post_url = encodeURIComponent(post_titleLinkObj.attr('href'));
            var post_desc = encodeURIComponent(jQuery(this).find('.post-body').text().substr(0,500));

            var buttonsHTML = '';
            for (var i=0; i < BloggerExtOptions.bookmark_buttons_bookmarklets.length; i++) {
                var img = BloggerExtOptions.bookmark_buttons_bookmarklets[i][0];
                var alt = BloggerExtOptions.bookmark_buttons_bookmarklets[i][1];
                var urlTempl = BloggerExtOptions.bookmark_buttons_bookmarklets[i][2];
                
                var url = urlTempl.replace('%URL%', post_url, "gm");
                url = url.replace('%TITLE%', post_title, "gm");
                url = url.replace('%DESC%', post_desc, "gm");
                
                buttonsHTML += '<a class="bookmark_button" href="'+url+'" alt="'+alt+'"><img src="'+img+'" alt="'+alt+'"></a>';
            }
            jQuery(this).find('.post-footer .post-icons').after( BloggerExtOptions.bookmark_buttons_template.replace('%BOOKMARK_BUTTONS%', buttonsHTML, "gm"));
    });
};
BloggerExt.register('bookmark_buttons' ,  {
    bookmark_buttons: true,
    bookmark_buttons_version: 1.0,
    bookmark_buttons_template: '<span class="post-bookmarks">%BOOKMARK_BUTTONS%</span>',
    bookmark_buttons_bookmarklets: [
        [ 
          'http://blogger.ext2.googlepages.com/hemidemi.gif',
          'HEMiDEMi',
          'http://www.hemidemi.com/user_bookmark/new?via=sticker&url=%URL%&title=%TITLE%&description=%DESC%' 
        ] ,
        [ 
          'http://blogger.ext2.googlepages.com/yahoo-myweb.png', 
          'Yahoo',
          'http://tw.myweb2.search.yahoo.com/myresults/bookmarklet?ei=UTF-8&u=%URL%&t=%TITLE%&d=%DESC%'
        ],
        [ 
          'http://blogger.ext2.googlepages.com/myshare.gif', 
          'MyShare',
          'http://myshare.url.com.tw/index.php?func=newurl&from=mysharepop&NewsMaster=1&url=%URL%&desc=%TITLE%&contents=%DESC%' 
        ],
        [ 
          'http://blogger.ext2.googlepages.com/delicious.png', 
          'del.icio.us',
          'http://del.icio.us/post?url=%URL%&title=%TITLE%' 
        ],
        [ 
          'http://blogger.ext2.googlepages.com/technorati.png', 
          'Technotati',
          'http://technorati.com/faves?sub=%TITLE%&add=%URL%' 
        ],
        [ 
          'http://blogger.ext2.googlepages.com/furl.gif', 
          'FURL',
          'http://furl.net/storeIt.jsp?&u=%URL%&t=%TITLE%' 
        ],
        [ 
          'http://blogger.ext2.googlepages.com/digg.png',
          'digg it!',
          'http://www.digg.com/submit?phase=2&url=%URL%&title=%TITLE%' 
        ]
    ]
});
BloggerExt.registerHook(BloggerExt.bookmark_buttons);

